<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>回复明细</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/systemStatic/style/admin.css">
    <link rel="stylesheet" href="${ctx}/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/css/public.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body>

<div style="height:485px; overflow:auto;background: #fff;">
    <form class="layui-form replyViewForm"  lay-filter="replyViewForm"
          style="padding:20px 28px 20px 0;background: #fff">
        <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-block">
                <input type="text" name="subject" readonly="readonly" lay-verify="subject" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">内容:</label>
            <div class="layui-input-block " style="padding:8px 0 0 0">
                <div class="layui-textarea">
                    <p id="showContent"></p>
                </div>
            </div>
        </div>
        <input type="hidden" name="id"/>
        <input type="hidden" name="content">

    </form>

    <ul class="layui-tab-title" style="background-color:white">

        <li class="layui-nav-item layui-this layim-this "><a id="reply">回复列表</a></li>
    </ul>

    <div  style="overflow-y: auto;overflow-x: hidden;">
        <div id="replyList">
            <table id="replyTable" lay-filter="replyTable" ></table>
        </div>
    </div>
</div>
<div class="layui-form-item">
    <div class="layui-input-block" style="width: 100%; text-align: center;position: absolute; bottom: 15px; margin: 0;">
        <a  class="layui-btn canUserView layui-btn-danger">关闭</a>
    </div>
</div>
<script src="${ctx}/public/component.js" type="text/javascript"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','table', 'layer', 'setter', 'commons', 'common', 'totalFilter', 'form', 'jquery', 'upload', 'layedit'], function () {
        var util = layui.util;
        var table = layui.table, layer = layui.layer, setter = layui.setter, commons = layui.commons,
            common = layui.common,
            totalFilter = layui.totalFilter, form = layui.form, $ = layui.jquery;
        var layedit = layui.layedit;
        var id = '${id}';

        //表格初始化
        table.render({
            elem: '#replyTable'
            , url: serverPath.systemPath + setter.sysLinkPath + 'messageReply/list?isUser=true&messageId=' + id
            , page: false
            , title: '数据库表信息'
            , height: '400px'
            , method: 'post'
            , cols: [[ //表头
                {field: 'reply', title: '回复人', sort: true}
                , {
                    field: 'replyTime', title: '回复时间', templet: function (d) {
                        if (d.replyTime == undefined) {
                            return "";
                        } else {
                            return util.toDateString(d.replyTime, "yyyy-MM-dd HH:mm:ss");
                        }
                    }
                }
                , {
                    field: 'content', title: '回复内容',
                    sort: true
                }
            ]]
        });

        //表单初始化
        $.ajax({
            url: serverPath.systemPath + setter.sysLinkPath + "messageSend/get",
            type: "get",
            contentType: 'application/json',
            dataType: 'json',
            data: {id: id},
            success: function (data) {
                if (commons._filterRecord(data)) {
                    var returnDate = data.data;
                    form.val('replyViewForm', {
                            "subject": returnDate.subject,
                            "sendTime": util.toDateString(returnDate.sendTime, "yyyy-MM-dd HH:mm:ss"),
                           /* "attachment": returnDate.attachment,*/
                            "content": returnDate.content,
                            "id": returnDate.id,
                            "userName": returnDate.userName
                        }
                    );
                    var content = $("input[name='content']").val();
                    $("#showContent").append(content)
                } else {
                    window.parent.layer.alert(data.msg);
                }
            }
        });
        $(".canUserView").click(function () {
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        })

        totalFilter.init('replyTable');
        //监听排序
        table.on('sort(replyTable)', function(obj){
            table.reload('replyTable', { //testTable是表格容器id
                where: {
                    orderField: obj.field //排序字段
                    ,orderSeq: obj.type //排序方式
                }
            });
        });
    });
</script>
</body>
</html>